Chapter 6

 Prograph Primitives

 t Prograph Primitives by Category  *245*
 t Prograph Primitives Descriptions

Prograph primitives are calls to compiled methods, supplied either by the system or by the user. The user can create custom primitives, which are treated by Prograph in exactly the same way as its own primitives. appendix II, “C Code Usage,” documents how this is done using a C compiler.

t
Prograph Primitives by Category  *245*

AppleTalk

ATP-Close
251
ATP-Get-Request
252
ATP-Get-Response
252
ATP-Open
252
ATP-Send-Request
253
ATP-Send-Response
253
NBP-Close
254
NBP-Confirm
254
NBP-Lookup
254
NBP-Open
255
NBP-Register
255

Application 

draw-style-text
256
find-item
256
find-menu
257
find-menu-a
257
find-window
258
find-window-a
258
is-double?
258
is-drag?
259
popup-menu
259
wait-double?
259

Bit

bit-and
260
bit-not
260
bit-or
260
bit-shift-l
261
bit-shift-r
261
bit-xor
261
test-all?
262
test-bit?
262
test-one?
262

Byte Stream

clear-bytes-map
263
from-bytes
264
to-bytes
264

Data

choose
265
copy
265
switch
265
shallow-copy
266

Datafile 

cluster-delete
494
cluster-first
495
cluster-lock
495
cluster-next
496
cluster-read
496
cluster-read-db
496
cluster-replace
497
cluster-undelete
497
cluster-unlock
498
cluster-write
498
db-backup
499
db-close
500
db-compact
500
db-delete
501
db-flush
501
db-get-flush
501
db-info
502
db-list
502
db-new
503
db-open
504
db-rename
504
db-set-flush
505
db-shutdown
505
db-wait
505
key-close
505
key-delete
506
key-find
506
key-first
506
key-info
507
key-last
507
key-list
507
key-new
508
key-next
508
key-open
509
key-previous
509
key-read
510
key-rename
510
key-value
511
table-close
511
table-delete
512
table-export
512
table-import
513
table-info
514
table-list
514
table-new
515
table-open
515
table-rename
516

Environment

gestalt
267
gestalt-attribute
268
trap?
268

File

close
269
create
269
delete
270
file-size
270
get-file
270
get-position
271
load
271
open
272
prograph-file
272
put-file
272
read
273
read-line
273
rename
274
save
274
set-position
275
write
275
write-line
275

Graphics

drag-rect
276
find-bounds
276
grow-rect
277
ints-to-point
277
ints-to-rect
278
ints-to-rgb
278
point-to-ints
278
points-to-rect
279
rect-to-ints
279
rect-to-points
280
rgb-to-ints
280

Instances

find-instance
281
inst-to-list
281
list-to-inst
282

Interpretercontrol

compiled?
283
debug
283
halt
283
trace
283

I/O

accept
284
answer
284
answer-v
285
ask
285
display
286
print-window
286
select
286
set-dialog-font
287
show
287

Lists

(in)
288
(join)
288
(length)
288
attach-l
289
attach-r
289
detach-l
289
detach-nth
290
detach-r
290
find-sorted
290
get-nth
291
insert-nth
291
make-list
292
pack
292
reverse
292
set-nth
293
set-nth!
293
sort
293
split-nth
294
unpack
294

Logical/Relational

<
295
<=
295
=
295
>
296
>=
296
and
297
not
297
or
297
xor
298
~=
298
≠
298
≤
299
≥
299

Math

*
300
**
300
+
301
++
301
+1
301
-
302
- -
302
-1
302
abs
303
acos
303
annuity
303
asin
304
atan
304
atan2
304
compound
305
cos
305
div
305
exp
306
idiv
306
ln
306
log10
307
max
307
min
307
pi
308
power
308
rand
308
round
308
round-down
309
round-up
309
set-seed
310
sign
310
sign-extend
310
sin
311
sqrt
311
tan
311
trunc
311
÷
312
÷÷
312

Memory

address-to-object
313
block-address
313
block-size
314
compact-memory
314
from-handle
314
from-pointer
314
get-integer
315
get-point
315
get-real
315
get-rect
316
get-string
316
get-text
316
lock-block
317
lock-string
317
make-direct
317
make-handle
317
make-pointer
318
new-block
318
object-to-address
319
put-integer
319
put-point
319
put-real
320
put-rect
320
put-string
320
put-text
321
string-address
321
to-handle
321
to-pointer
322
unlock-block
322
unlock-string
322

Serial Port

break-serial-port
324
close-serial-port
324
configure-sport
325
count-sport-input
325
get-sport-buffer
326
get-sport-refs
326
kill-serial-port
326
open-serial-port
327
receive-serial-port
327
send-serial-port
327
send-sport-done
328
set-sport-buffer
328
sport-configuration
329

Strings

"in"
330
"join"
330
"length"
331
byte-length
331
format
331
from-ascii
334
from-string
334
integer-to-string
335
middle
335
munge-string
335
prefix
335
string-length
336
string-to-integer
336
suffix
337
to-ascii
337
to-string
337
tokenize
338

System

ancestors
339
attr-com
339
attributes
340
called-from-get
340
called-from-meth
340
called-from-set
341
calls-to-get
341
calls-to-meth
342
calls-to-set
342
children
342
class-com
343
classes
343
descendants
343
meth-com
343
meth-com-g
344
meth-com-s
344
methods
344
pers-com
345
persistents
345
settable
345

System Class 

sc-activate-wind
346
sc-aevent-begin
346
sc-aevent-dispatch
347
sc-aevent-end
347
sc-background?
348
sc-begin-drawing
348
sc-begin-update
348
sc-click-witem
349
sc-delete-item
349
sc-draw-witem
350
sc-end-drawing
350
sc-end-update
350
sc-find-witem
351
sc-get-wind
351
sc-hilite-witem
351
sc-idle-edit
352
sc-insert-item
352
sc-key-button
352
sc-key-edit
353
sc-key-list
353
sc-key-menu
354
sc-show-balloon
354
sc-tab-witem
354
sc-zoom-wind
355

Text

auto-text
356
clear-text
356
copy-text
356
cut-text
357
extract-text
357
insert-text
357
paste-text
357
print-text
358

Type

boolean?
359
external-type
359
instance?
359
integer?
360
list?
360
mac-type
360
number?
361
real?
361
string?
361
type
362

t
Prograph Primitives Descriptions *248*

Certain supplied primitives perform tests or manipulate boolean input values to obtain a boolean result. Every such boolean primitive can either have one root, in which case it returns TRUE or FALSE, or no roots, in which case it succeeds or fails. If a boolean primitive is used without a root, it should have an associated control so that possible failure of the operation does not result in an execution error. 

The boolean primitives are those in the category Logical/Relational, or those whose names end with a question mark (?).

Some primitives accept an input (or produce an output) of more than one type. In the descriptions of primitives below, such an input (or output) is given a set of identifiers corresponding to the set of possible types. For example, see below the primitive find-item, the second input of which is given the two identifiers ItemName and ItemIndex, corresponding to the two acceptable types string and integer.  *249*

When an input or output is optional, its corresponding type is given within square brackets ( [ ] ).  For example, in the Application category, see the primitive is-drag?, the output of which is optional and so is indicated in output types as [boolean]. 

Certain primitives have a list and one or more integers as input, where the integers are indeces into the list or the list of lists. If such a primitive receives an integer less than 1 or greater than the length of the list it accesses, an execution error occurs.

In order to support internationalization and non-Roman scripts, aliases have been created for those primitives with names made up of characters with ASCII values greater than 127. These primitives are ≤, ≥, ≠, ÷, and ÷÷. Their aliases are <=, >=, ~=, div, and idiv, respectively.